/*****************************************************************************

  The following code is derived, directly or indirectly, from the SystemC
  source code Copyright (c) 1996-2006 by all Contributors.
  All Rights reserved.

  The contents of this file are subject to the restrictions and limitations
  set forth in the SystemC Open Source License Version 2.4 (the "License");
  You may not use this file except in compliance with such restrictions and
  limitations. You may obtain instructions on how to receive a copy of the
  License at http://www.systemc.org/. Software distributed by Contributors
  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
  ANY KIND, either express or implied. See the License for the specific
  language governing rights and limitations under the License.

 *****************************************************************************/

/*****************************************************************************

  pkt.h - This file defines a ethernet frame

  Original Author: Xinming Chen

 *****************************************************************************/

/*****************************************************************************

  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
  changes you are making here.

      Name, Affiliation, Date:
  Description of Modification:

 *****************************************************************************/

#include "systemc.h"
#include "mac.h"
#undef OUTPUT_PACKET
#define PORTNUM 4
#define PKT_LENGTH 2000
#define BIT_CLK_PERIOD 1//in ns
#define BYTE_CLK_PERIOD 8//in ns
#define SW_CLK_PERIOD 10000//in ns
#define TM_CLK_PERIOD 8//in ns, 1Gbps
#define __LITTLE_ENDIAN_BITFIELD
struct pkt
{
    unsigned char *data;
    unsigned int pkt_length;
    pkt()
    {
	data=new unsigned char[PKT_LENGTH];
}
    ~pkt()
    {
        if(data)
        {
            delete [] data;
            data = NULL;
        }
    }
    pkt(const pkt &a)
    {
        data = new unsigned char[PKT_LENGTH];
        memcpy(this->data, a.data, a.pkt_length);
        this->pkt_length = a.pkt_length;
    }
    inline bool operator == (const pkt &rhs) const
    {
        return false;
    }
    inline pkt &operator =(const pkt &a)
    {
        //data = new unsigned char[PKT_LENGTH];
        memcpy(this->data, a.data, a.pkt_length);
        this->pkt_length = a.pkt_length;
        return *this;
    }
};

inline
ostream &
operator << (ostream &os, const pkt &a)
{
    os << "streaming of struct pkt not implemented";
    return os;
}

inline
void
#if defined(SC_API_VERSION_STRING)
sc_trace(sc_trace_file *tf, const pkt &a, const std::string &name)
#else
sc_trace(sc_trace_file *tf, const pkt &a, const sc_string &name)
#endif
{
}

struct csix_base_hdr
{
#if defined(__LITTLE_ENDIAN_BITFIELD)
    unsigned char ready: 2,
             type: 4,
             cr: 1,
             p: 1;
    unsigned char length;
#elif defined(__BIG_ENDIAN_BITFIELD)
    unsigned char p: 1,
             cr: 1,
             type: 4,
             ready: 2;
    unsigned char length;
#endif
};

struct csix_l2_hdr
{
    unsigned short frag_ID;
    unsigned short total_length;
    unsigned short frag_offset;
    unsigned char frag_length;
    unsigned char dst_port;
};

